The Good, the Bad, and the Ugly: An Empirical Study of Implicit Type Conversions in JavaScript

نویسندگان

  • Michael Pradel
  • Koushik Sen
چکیده

Most popular programming languages support situations where a value of one type is converted into a value of another type without any explicit cast. Such implicit type conversions, or type coercions, are a highly controversial language feature. Proponents argue that type coercions enable writing concise code. Opponents argue that type coercions are error-prone and that they reduce the understandability of programs. This paper studies the use of type coercions in JavaScript, a language notorious for its widespread use of coercions. We dynamically analyze hundreds of programs, including real-world web applications and popular benchmark programs. We find that coercions are widely used (in 80.42% of all function executions) and that most coercions are likely to be harmless (98.85%). Furthermore, we identify a set of rarely occurring and potentially harmful coercions that safer subsets of JavaScript or future language designs may want to disallow. Our results suggest that type coercions are significantly less evil than commonly assumed and that analyses targeted at real-world JavaScript programs must consider coercions. 1998 ACM Subject Classification D.3.3 Language Constructs and Features, F.3.2 Semantics of Programming Languages, D.2.8 Metrics

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Good, bad and ugly: Exploring the Machiavellian power dynamics of leadership in medical education

Introduction: Medical education requires participation of variousstakeholders and this contributes to power dynamics operating atmultiple levels. Personality traits of an individual can affect thesmooth execution of the educational programmes and eventuallythe professionalism of the environment. With the increased focuson leadership traits in medical education and collaboration inhealth care se...

متن کامل

Optimisation of Healthcare Contracts: Tensions Between Standardisation and Innovation; Comment on “Competition in Healthcare: Good, Bad or Ugly?”

An important determinant of health system performance is contracting. Providers often respond to financial incentives, despite the ethical underpinnings of medicine, and payers can craft contracts to influence performance. Yet contracting is highly imperfect in both single-payer and multi-payer health systems. Arguably, in a competitive, multi-payer environment, contractual innovation may occur...

متن کامل

Competition in Healthcare: Good, Bad or Ugly?

The role of competition in healthcare is much debated. Despite a wealth of international experience in relation to competition, evidence is mixed and contested and the debate about the potential role for competition is often polarised. This paper considers briefly some of the reasons for this, focusing on what is meant by “competition in healthcare” and why it is more valuable to think about th...

متن کامل

Refactoring Legacy JavaScript Code to Use Classes: The Good, The Bad and The Ugly

JavaScript systems are becoming increasingly complex and large. To tackle the challenges involved in implementing these systems, the language is evolving to include several constructions for programmingin-the-large. For example, although the language is prototype-based, the latest JavaScript standard, named ECMAScript 6 (ES6), provides native support for implementing classes. Even though most m...

متن کامل

Scala.js: Type-Directed Interoperability with Dynamically Typed Languages

Interoperability between statically typed and dynamically typed languages is increasingly important, as can be witnessed by the many statically typed languages targeting JavaScript. Interoperating with both the object-oriented and functional features of JavaScript is essential, if only to manipulate the DOM, yet existing languages have very poor support for this. We present Scala.js, a dialect ...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2015